/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Componentes.Validators;

import java.awt.Color;
import javax.swing.JComponent;
import org.jdesktop.beansbinding.Validator;

/**
 *
 * @author luisramirezmartinez SAMI 2011
 *
 */
public class GenericValidator extends Validator<String> {
    
    private int min=0;
    private int max=0;
    private JComponent obj;
    
    
    
 
    
    
    public GenericValidator(){

    }

    @Override
    public Result validate(String val) {
        
        if(val.trim().length()<min || val.trim().length()>max){
            
                getObj().setBackground(Color.pink);
              
            return new Result(null, "esta fuera de rango.");
        }
        
        
                getObj().setBackground(Color.white);
              
  
        return null;
       
    }


    public int getMin() {
        return min;
    }


    public void setMin(int min) {
        this.min = min;
    }

    public int getMax() {
        return max;
    }

 
    public void setMax(int max) {
        this.max = max;
    }

    /**
     * @return the obj
     */
    public JComponent getObj() {
        return obj;
    }

    /**
     * @param obj the obj to set
     */
    public void setObj(JComponent obj) {
        this.obj = obj;
    }

  

}
